package com.th.apicenter.youku;

import com.th.apicenter.baidu.entity.ThBaiduData;
import com.th.apicenter.youku.entity.ThYoukuData;
import com.th.apicenter.youku.service.YoukuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.awt.*;
import java.util.Date;

/**
 * @author kay
 * @date 2025/7/1
 * @TODO
 */
@RestController
@RequestMapping("/yk")
@Slf4j
public class YoukuController {

    @Autowired
    private YoukuService youkuService;

    /**
     * https://apibiz.tinghongzz.com/yk/receive?account_id=31409002&os=__OS__&ip=__IP__&idfa=__IDFA__&oaid=__OAID__&imei=__IMEI__&androidid=__ANDROIDID__&mac=__MAC__&caid=__CAID__&trackid=__TRACKID__&creativeid=__CREATIVEID__&requestid=__REQUESTID__&planid=__PLANID__&groupid=__GROUPID__&advertiserid=__ADVERTISERID__&appkey=__APPKEY__&ua=__UA__&timestamp=__TIMESTAMP__&utdid=__UTDID__&clickid=__CLICKID__&pname=__PNAME__&model=__MODEL__
     */
    @GetMapping("/receive")
    public void receiveUrl(@RequestParam(name = "account_id", required = false) String account_id,
                           @RequestParam(name = "os", required = false) String os,
                           @RequestParam(name = "ip", required = false) String ip,
                           @RequestParam(name = "idfa", required = false) String idfa,
                           @RequestParam(name = "oaid", required = false) String oaid,
                           @RequestParam(name = "imei", required = false) String imei,
                           @RequestParam(name = "androidid", required = false) String androidid,
                           @RequestParam(name = "mac", required = false) String mac,
                           @RequestParam(name = "trackid", required = false) String trackid,
                           @RequestParam(name = "creativeid", required = false) String creativeid,
                           @RequestParam(name = "requestid", required = false) String requestid,
                           @RequestParam(name = "planid", required = false) String planid,
                           @RequestParam(name = "groupid", required = false) String groupid,
                           @RequestParam(name = "advertiserid", required = false) String advertiserid,
                           @RequestParam(name = "appkey", required = false) String appkey,
                           @RequestParam(name = "ua", required = false) String ua,
                           @RequestParam(name = "timestamp", required = false) String timestamp,
                           @RequestParam(name = "utdid", required = false) String utdid,
                           @RequestParam(name = "clickid", required = false) String clickid,
                           @RequestParam(name = "pname", required = false) String pname,
                           @RequestParam(name = "model", required = false) String model) {
        ThYoukuData thYoukuData = new ThYoukuData();
        thYoukuData.setAccountId(account_id);
        thYoukuData.setOs(os);
        thYoukuData.setIp(ip);
        thYoukuData.setIdfa(idfa);
        thYoukuData.setOaid(oaid);
        thYoukuData.setImei(imei);
        thYoukuData.setAndroidid(androidid);
        thYoukuData.setMac(mac);
        thYoukuData.setTrackid(trackid);
        thYoukuData.setCreativeid(creativeid);
        thYoukuData.setRequestid(requestid);
        thYoukuData.setPlanid(planid);
        thYoukuData.setGroupid(groupid);
        thYoukuData.setAdvertiserid(advertiserid);
        thYoukuData.setAppkey(appkey);
        thYoukuData.setUa(ua);
        thYoukuData.setTimestamp(timestamp);
        thYoukuData.setUtdid(utdid);
        thYoukuData.setClickid(clickid);
        thYoukuData.setPname(pname);
        thYoukuData.setModel(model);
        thYoukuData.setCreateDate(new Date());
        youkuService.receive(thYoukuData);
    }
}
